using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Reflection;
using SigmaStock_Components;

namespace project
{


    static class Program
    {

        static public List<string> form_names = new List<string>();
        static public List<Form> form_refs = new List<Form>();
        static public Form active_form;
        static public string active_form_name;
        static public Form main_form;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]

        static public void SaveAndInvoke(string currform_type,Form curr_form,string invoketype)
        {
            if (currform_type.Equals("MainForm"))
            {
                main_form = curr_form;
            }
            form_names.Add(currform_type);
            form_refs.Add(curr_form);
            curr_form.Hide();
            Assembly frmMain = Assembly.GetEntryAssembly();
            Type formType = frmMain.GetType(invoketype);            
            active_form = (Form)Activator.CreateInstance(formType);
            active_form.ShowDialog();
        //    Application.Run(active_form);      
            
        }

        static public void Invoke(Form curr_form, string invoketype)
        {
            curr_form.Close();
            Assembly frmMain = Assembly.GetEntryAssembly();
            Type formType = frmMain.GetType(invoketype);
            active_form = (Form)Activator.CreateInstance(formType);
            active_form.Show();
        }

        static public void InvokePar(Form curr_form, string invoketype,params object[] list)
        {
//            curr_form.Close();
            Console.WriteLine(invoketype);
            foreach (object o in list)
            {
                Console.WriteLine(o);
            }
            Assembly frmMain = Assembly.GetAssembly(typeof(Magazine_Retailer));
            Type formType = frmMain.GetType(invoketype);
            active_form = (Form)Activator.CreateInstance(formType,list);
            active_form.ShowDialog();
        }

        static public void InvokeModal(Form curr_form, string invoketype)
        {
            curr_form.Close();
            Assembly frmMain = Assembly.GetEntryAssembly();
            Type formType = frmMain.GetType(invoketype);
            active_form = (Form)Activator.CreateInstance(formType);
            active_form.ShowDialog();
        }

        static public void InvokeModalNoClose(Form curr_form, string invoketype)
        {
            Assembly frmMain = Assembly.GetEntryAssembly();
            Type formType = frmMain.GetType(invoketype);
            active_form = (Form)Activator.CreateInstance(formType);
            active_form.ShowDialog();
        }


        static public Form ReturnFormInstance(Form curr_form, string invoketype)
        {
            Assembly frmMain = Assembly.GetEntryAssembly();
            Type formType = frmMain.GetType(invoketype);
            active_form = (Form)Activator.CreateInstance(formType);
            return active_form;
        }

        static Form currform
        {
            get{
                return active_form;
            }

        }


        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);            
            Application.Run(new Main_Form());

          
        }
    }
}